import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import intl from 'utils/intl';
import { getCurrentOrganizationId } from 'utils/utils';
import { CPAAS_PLATFORM } from 'utils/config';
var organizationId = getCurrentOrganizationId();
var treeDS = {
  autoQuery: true,
  selection: 'single',
  primaryKey: 'positionId',
  idField: 'positionId',
  parentField: 'parentPositionId',
  fields: [{
    name: 'positionId',
    type: 'string'
  }, {
    name: 'positionCode',
    type: 'string'
  }, {
    name: 'positionName',
    type: 'string'
  }],
  transport: {
    read: function read(config) {
      var url = "".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/positions");
      return {
        config: config,
        url: url,
        method: 'GET',
        params: {
          customizeUnitCode: 'CPFM.ORG_LIST.POSITION.BACIS'
        }
      };
    }
  }
};
var searchCompanyAndDepartmentDS = {
  fields: [{
    name: 'companyLov',
    type: 'object',
    lovCode: 'CPFM.UNIT.COMPANY',
    lovPara: {
      tenantId: organizationId
    },
    label: intl.get('cpfm.organization.model.position.searchCompanyName').d('公司名称'),
    noCache: true,
    ignore: 'always'
  }, {
    name: 'unitCompanyId',
    type: 'string',
    bind: 'companyLov.unitId'
  }, {
    name: 'departmentLov',
    type: 'object',
    lovCode: 'CPFM.PLUS.ALL.DEPARTMENT',
    lovPara: {
      tenantId: organizationId
    },
    cascadeMap: {
      unitCompanyId: 'companyLov.unitId'
    },
    label: intl.get('cpfm.organization.model.position.searchDepartmentName').d('部门名称'),
    noCache: true,
    ignore: 'always'
  }, {
    name: 'unitDepartmentId',
    type: 'string',
    bind: 'departmentLov.unitId'
  }]
};
var baseInfoDs = {
  fields: [{
    name: 'positionCode',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.positionCode').d('岗位编码'),
    format: 'uppercase'
  }, {
    name: 'positionName',
    type: 'intl',
    label: intl.get('cpfm.organization.model.position.positionName').d('岗位名称')
  }, {
    name: 'unitCompanyName',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.company').d('公司')
  }, {
    name: 'parentPositionName',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.parentPositionName').d('上级岗位')
  }, {
    name: 'unitName',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.department').d('部门')
  }, {
    name: 'supervisorFlag',
    trueValue: 1,
    falseValue: 0,
    type: 'boolean',
    label: intl.get('cpfm.organization.model.position.supervisorFlag').d('主管岗位')
  }, {
    name: 'enabledFlag',
    trueValue: 1,
    falseValue: 0,
    type: 'boolean',
    label: intl.get('cpfm.organization.model.position.status').d('状态')
  }]
};
var formDS = {
  fields: [{
    name: 'positionId',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.positionId').d('岗位ID')
  }, {
    name: 'parentPositionId',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.parentPositionId').d('父岗位ID')
  }, {
    name: 'positionCode',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.positionCode').d('岗位编码'),
    format: 'uppercase',
    required: true
  }, {
    name: 'positionName',
    type: 'intl',
    label: intl.get('cpfm.organization.model.position.positionName').d('岗位名称'),
    required: true
  }, {
    name: 'companyLov',
    type: 'object',
    lovCode: 'CPFM.UNIT.COMPANY',
    lovPara: {
      tenantId: organizationId
    },
    label: intl.get('cpfm.organization.model.position.suoShuCompanyName').d('所属公司'),
    noCache: true,
    ignore: 'always',
    required: true
  }, {
    name: 'unitCompanyName',
    type: 'string',
    bind: 'companyLov.unitName'
  }, {
    name: 'unitCompanyId',
    type: 'string',
    bind: 'companyLov.unitId'
  }, {
    name: 'tempUnitId',
    type: 'string',
    bind: 'companyLov.unitId'
  }, {
    name: 'departmentLov',
    type: 'object',
    lovCode: 'CPFM.PLUS.UNIT.DEPARTMENT',
    cascadeMap: {
      unitCompanyId: 'tempUnitId'
    },
    label: intl.get('cpfm.organization.model.position.suoShuDepartmentName').d('所属部门'),
    noCache: true,
    ignore: 'always',
    required: true
  }, {
    name: 'unitName',
    type: 'string',
    bind: 'departmentLov.unitName'
  }, {
    name: 'parentPositionLov',
    type: 'object',
    lovCode: 'CPFM.PARENT_POSITION',
    cascadeMap: {
      positionId: 'positionId'
    },
    label: intl.get('cpfm.organization.model.position.SuperiorPost').d('上级岗位'),
    noCache: true,
    ignore: 'always'
  }, {
    name: 'parentPositionId',
    type: 'string',
    bind: 'parentPositionLov.positionId'
  }, {
    name: 'parentPositionName',
    type: 'string',
    bind: 'parentPositionLov.positionName'
  }, {
    name: 'unitId',
    type: 'string',
    bind: 'departmentLov.unitId'
  }, {
    name: 'orderSeq',
    type: 'number',
    min: 0,
    label: intl.get('cpfm.organization.model.position.orderSeq').d('排序号'),
    required: true
  }, {
    name: 'description ',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.description').d('描述')
  }, {
    name: 'supervisorFlag',
    trueValue: 1,
    falseValue: 0,
    type: 'boolean',
    label: intl.get('cpfm.organization.model.position.supervisorFlag').d('主管岗位')
  }, {
    name: 'enabledFlag',
    trueValue: 1,
    falseValue: 0,
    type: 'boolean',
    label: intl.get('cpfm.organization.model.position.status').d('状态')
  }],
  transport: {
    create: function create(config) {
      var data = config.data,
          params = config.params,
          dataSet = config.dataSet;
      var _data$0$unitId = data[0].unitId,
          unitId = _data$0$unitId === void 0 ? '' : _data$0$unitId;
      var unitCompanyId = dataSet.queryParameter.unitCompanyId;
      var url = "".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/companies/").concat(unitCompanyId, "/units/").concat(unitId, "/position");
      return {
        data: _objectSpread(_objectSpread({}, data[0]), {}, {
          unitCompanyId: unitCompanyId
        }),
        params: _objectSpread(_objectSpread({}, params), {}, {
          customizeUnitCode: 'CPFM.ORG_LIST.DEPARTMENT.POSITION.EDIT'
        }),
        url: url,
        method: 'POST'
      };
    }
  }
};
var employeeTableDS = {
  selection: false,
  dataKey: 'content',
  fields: [{
    name: 'employeeCode',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.employeeCode').d('员工编码')
  }, {
    name: 'name',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.name').d('姓名')
  }, {
    name: 'quickIndex',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.quickIndex').d('快速检索')
  }, {
    name: 'phoneticize',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.phoneticize').d('拼音')
  }, {
    name: 'email',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.email').d('邮箱')
  }, {
    name: 'mobile',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.mobile').d('手机号码')
  }, {
    name: 'joinDate',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.joinDate').d('入职日期')
  }, {
    name: 'status',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.employeeStatus').d('员工状态')
  }, {
    name: 'statusName',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.statusName ').d('状态名称')
  }, {
    name: 'unitId',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.unitId').d('部门ID')
  }, {
    name: 'unitName',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.unitName').d('部门名称')
  }, {
    name: 'bornDate',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.bornDate').d('出生日期')
  }, {
    name: 'certificateId',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.certificateId').d('证件ID')
  }, {
    name: 'certificateType',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.certificateType ').d('证件类型')
  }, {
    name: 'effectiveEndDate',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.effectiveEndDate').d('证件失效日期')
  }, {
    name: 'effectiveStartDate',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.effectiveStartDate').d('证件生效日期')
  }, {
    name: 'employeeId',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.employeeId').d('员工表ID')
  }, {
    name: 'enabledFlag',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.enabledFlag').d('员工表ID')
  }, {
    name: 'gender',
    type: 'number',
    label: intl.get('cpfm.organization.model.position.gender').d('性别')
  }, {
    name: 'nameEn',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.nameEn ').d('英文名')
  }, {
    name: 'phoneticize',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.phoneticize').d('拼音')
  }, {
    name: 'positionId',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.positionId').d('岗位ID')
  }, {
    name: 'primaryPositionFlag',
    type: 'number',
    label: intl.get('cpfm.organization.model.position.isPrimaryPositionFlag').d('主岗')
  }, {
    name: 'positionName',
    type: 'string',
    label: intl.get('cpfm.organization.model.position.positionName').d('岗位名称')
  }],
  transport: {
    read: function read(config) {
      var data = config.data,
          params = config.params,
          dataSet = config.dataSet;
      var positionId = data.positionId;
      var url = "".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/positions/user/").concat(positionId);

      if (positionId !== 0) {
        return {
          params: params,
          url: url,
          method: 'GET'
        };
      } else {
        dataSet.loadData([]);
      }
    }
  }
};
export { treeDS, searchCompanyAndDepartmentDS, formDS, employeeTableDS, baseInfoDs };